'use strict';

/**
 * @description: tree data -> 扁平树
 * @param origin 数据源
 * @return treedata
 */
function toFlatTree(origin) {
    return origin.reduce((res, item) => {
        const { children, ...i } = item;
        return res.concat(i, children && children.length ? toFlatTree(children) : []);
    }, []);
}

exports.toFlatTree = toFlatTree;
